package com.sc.nft.dao;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dto.ReleaseFrozenPointsDTO;
import com.sc.nft.entity.vo.ecology.AdminExpiredRecordsVO;
import com.sc.nft.entity.vo.ecology.MyPointsRecordsVO;
import com.sc.nft.enums.EcologyIncomeTypeEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserEcologyPointsQuotaRecords;
import com.sc.nft.mapper.UserEcologyPointsQuotaRecordsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 用户生态燃料额度记录表(user_ecology_points_quota_records)数据DAO
 *
 * @author Sun
 * @since 2023-11-23 11:22:44
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserEcologyPointsQuotaRecordsDao extends ServiceImpl<UserEcologyPointsQuotaRecordsMapper, UserEcologyPointsQuotaRecords> {

    public Page<AdminExpiredRecordsVO> expiredRecords(Long userId, EcologyIncomeTypeEnum incomeType, Date startTime, Date endTime, Page page) {
        return baseMapper.expiredRecords(page,userId, ObjectUtil.isNull(incomeType) ? null : incomeType.getCode(), startTime, endTime);
    }

    public Page<MyPointsRecordsVO> stayReleaseRecords(Long userId, Integer pageNo, Integer pageSize) {
        return baseMapper.stayReleaseRecords(new Page(pageNo,pageSize),userId);
    }

    public Page<MyPointsRecordsVO> myExpiredRecords(Long userId, Integer pageNo, Integer pageSize) {
        return baseMapper.myExpiredRecords(new Page(pageNo,pageSize),userId);
    }

    public UserEcologyPointsQuotaRecords stayReleaseRecordsByUserIdAndOne(Long userId) {
        return baseMapper.stayReleaseRecordsByUserIdAndOne(userId);
    }

    public Boolean subFreezeAmountAndSubReleaseAmountById(Long id, BigDecimal freezeAmount) {
        return baseMapper.subFreezeAmountAndSubReleaseAmountById(id,freezeAmount);
    }

    public BigDecimal getSumFrozenEcologyPoints() {
        return baseMapper.getSumFrozenEcologyPoints();
    }

    public List<ReleaseFrozenPointsDTO> releaseFrozenPoints() {
        return baseMapper.releaseFrozenPoints();
    }

    public Boolean removeAll() {
        return baseMapper.removeAll();
    }
}